package com.tanhua.manage.service;



import com.alibaba.dubbo.config.annotation.Reference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.server.api.QuanZiApi;
import com.tanhua.dubbo.server.pojo.Videos;
import com.tanhua.manage.mapper.UserInfoMapper;
import com.tanhua.manage.pojo.UserInfo;
import com.tanhua.manage.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class VideoService {

    @Reference(version = "1.0.0")
    private QuanZiApi quanZiApi;

    @Autowired
    private UserInfoMapper userInfoMapper;

    public PageResult queryVideoList(String pageSize, String page, String sortProp, String sortOrder, String uid) {
        List<Videos> videoList = this.quanZiApi.queryVideoList(page,pageSize,sortProp,sortOrder,uid);
        //注入
        for (Videos videos : videoList) {
            QueryWrapper<UserInfo> queryWrapper = new QueryWrapper();
            queryWrapper.eq("user_id",videos.getUserId());
            UserInfo userInfo = this.userInfoMapper.selectOne(queryWrapper);
            videos.setNickname(userInfo.getNickName());
        }
        PageResult pageResult = new PageResult();
        pageResult.setPages(0);
        pageResult.setPage(Integer.valueOf(page));
        pageResult.setPagesize(Integer.valueOf(pageSize));
        pageResult.setCounts(0);
        pageResult.setItems(videoList);
        return pageResult;
    }
}
